import { RouteRecordRaw, createRouter, createWebHashHistory } from 'vue-router';
import NProgress from 'nprogress';
import 'nprogress/nprogress.css';
const routes: Array<any> = [
    {
        path: "/",
        redirect: "/login",
    },
    {
        path: "/login",
        name: "login",
        title: "登录",
        component: () => import("@/pages/login/index.vue"),
    },
    {
        path: "/home",
        name: "home",
        title: "首页",
        component: () => import("@/pages/home/index.vue"),
    },
    {
        path: "/cultivated",
        name: "cultivated",
        title: "耕地质量检测平台",
        component: () => import("@/pages/cultivated/index.vue"),
    },
    {
        path: "/soil-plane",
        name: "soil-plane",
        title: "土壤墒情监测统计平台",
        component: () => import("@/pages/soil/plane.vue"),
    },
    {
        path: "/soil",
        name: "soil",
        title: "土壤墒情",
        component: () => import("@/pages/soil/index.vue"),
    },
    {
        path: "/greenhouse",
        name: "greenhouse",
        title: "智慧大棚",
        component: () => import("@/pages/greenhouse/index.vue"),
    },
    {
        path: "/ai",
        name: "ai",
        title: "智慧农业",
        component: () => import("@/pages/ai/index.vue"),
    },
    {
        path: "/corn",
        name: "corn",
        title: "玉米",
        component: () => import("@/pages/corn/index.vue"),
    },
    {
        path: "/corn-plane",
        name: "corn-plane",
        title: "玉米统计",
        component: () => import("@/pages/corn/plane.vue"),
    },
]

export const router = createRouter({
    history: createWebHashHistory(),
    routes,
});

router.beforeEach(async (to, from, next) => {
    NProgress.configure({ showSpinner: true });
    next()
})
router.afterEach(() => {
    NProgress.done()
})
export default router